﻿var weightVehicleInfo;

function updataDataVehicleWeightByDistrict(para1,para2,para3,para4) {
    weightVehicleInfo.removeAll();
    weightVehicleInfo.load({
        params: { clientName: para1, dateString: para2, type: para3, name: para4, op: 'GetVehicleWeightByDistrict'}//区名、日期、中转站or处理厂、中转站类型or处理厂类型
//        params: { clientName: clientName, dateString: date, name: "天津滨海新区垃圾焚烧发电厂", op: 'GetVehicleWeightByFactoryAndDistrictBh' }
                    , callback: function (records, options, success) {
                        if (success && records.length) {
                            Ext.getCmp("label2").setValue(records[0].get("dateAll"));
                            Ext.getCmp("label3").setValue(records[0].get("weightAll"));
                        }
                    }
    });
}

function createWeightVehiclePanel() {
//    var p = new Ext.Panel({
////        title: ' My Panel ', // 标题
//        collapsible: true, // 右上角上的那个收缩按钮，设为false则不显示
//        renderTo: 'WeightVehicleInfoList', // 这个panel显示在html中id为container的层中
//        anchor: '100% 100%',
////        html: " <p>我是内容，我包含的html可以被执行！</p> " //panel 主体中的内容，可以执行html代码
//        items: [createPanelWeightVehicleTitle(), {
//            layout: 'fit',
//            items: [createGridPanelWeightVehicle()]
//        }]
    //    });
    var p = new Ext.Panel({
        renderTo: 'WeightVehicleInfoList',
        region: 'center',

        //            title: '处理厂按区统计',
        anchor: '100% 100%',
        closable: true,
        autoScroll: true,
        containerScroll: true,
        //margins: '0 0 0 5',
        border: false,
        iconCls: 'nav',
        items: [createPanelWeightVehicleTitle(), {
            layout: 'fit',
            items: [createGridPanelWeightVehicle()]
        }]
    });
}

function createPanelWeightVehicleTitle() {
    return new Ext.Panel({
        frame: true,
        bodyStyle: 'padding:0px 0px 0',
        items: [{
                                    height: 30,
                                    layout: { type: 'hbox' },
                                    items: [
                                    {
                                        width: 200,
                                        xtype: "label",
                                        id: "label1",
                                        text:"123"
                                    },{
                                        width: 200,
                                        xtype: "label",
                                        id: "label2",
                                        text: "234"

                                    },{
                                        width: 200,
                                        xtype: "label",
                                        id: "label3",
                                        text: "345"

                                    }]
                                }]

    });
}

function createGridPanelWeightVehicle() {
    // 列
    var cm = new Ext.grid.ColumnModel([
        { dataIndex: 'name', sortable: true, width: 60 },
    //        { header: '报警类型', dataIndex: 'Alarm_Type', sortable: true, renderer: GetAlarmTypeString, width: 64 },
        { dataIndex: 'dunCount', sortable: true, width: 58 }
        ]);

    // 数据源
    weightVehicleInfo = new Ext.data.Store({
        url: "../Json/JsonGetWeightInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'name' }, { name: 'dunCount' }, { name: 'dateAll' }, { name: 'weightAll'}])
            )
    });

    return new Ext.grid.GridPanel({
        anchor: '100%',
        layout: 'fit',
        enableHdMenu: false,
        autoScroll: true,
        containerScroll: true,
        autoHeight: true,
        //title: '报警列表',
        loadMask: { msg: '正在加载数据，请稍侯……' },
        //el: 'grid',
        store: weightVehicleInfo,
        cm: cm,
        //bbar: bbar,
        bodyStyle: 'height:100%',
        viewConfig: {
            forceFit: true
        }
    });

}